<template>
  <div>
    <h1>使用同一个过滤器处理7777777时间戳</h1>
    时间：{{ time | Time('-') }}<br />
    时间：{{ time | Time('/') }}
  </div>
</template>

<script>
export default {
  data () {
    return {
      time: new Date(),
      str: ''
    }
  },
  filters: {
    Time: function (str, time) {
      if (str === '-') {
        const y = time.getFullYear()
        const m = (time.getMonth() + 1).toString().padStart(2, 0)
        const d = time.getDate().toString().padStart(2, 0)
        return `${y}-${m}-${d}`
      } else {
        const y = time.getFullYear()
        const m = (time.getMonth() + 1).toString().padStart(2, 0)
        const d = time.getDate().toString().padStart(2, 0)
        return `${y}/${m}/${d}`
      }
    }
  }
}
</script>
